package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.RoomBean;
import com.project.mapper.IRoomMapper;
import com.project.service.IRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class RoomServiceImpl implements IRoomService {
    @Autowired
    private IRoomMapper mapper;

    @Override
    public void add(RoomBean room) {
        mapper.add(room);
    }

    @Override
    public void del(int id) {
        mapper.del(id);
    }

    @Override
    public void update(int id, int price) {
        mapper.update(id, price);
    }

    @Override
    public RoomBean findById(int id) {
        return mapper.findById(id);
    }

    @Override
    public PageInfo<RoomBean> findByItem(int pageNo, String address, Integer startPrice, Integer endPrice) {
        PageHelper.startPage(pageNo,PAGESIZE);
        PageInfo<RoomBean> info = PageInfo.of(mapper.findByItem(address, startPrice, endPrice));

        return info;
    }
}
